.class public Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;
.super Ljava/lang/Object;
.source "ButtonHelperGps.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$onUiListener;
    }
.end annotation


# instance fields
.field private buttonConnect:Landroid/widget/LinearLayout;

.field private buttonRefresh:Landroid/widget/LinearLayout;

.field private connectDrawable:Landroid/widget/ImageView;

.field private connectText:Landroid/widget/TextView;

.field private ctx:Landroid/content/Context;

.field private devices:Landroid/widget/Spinner;

.field private devicesAdapter:Landroid/widget/ArrayAdapter;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Landroid/widget/ArrayAdapter<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private onUiInteraction:Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$onUiListener;

.field private pairedDevices:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Landroid/bluetooth/BluetoothDevice;",
            ">;"
        }
    .end annotation
.end field

.field private progressRefreshing:Landroid/widget/ProgressBar;

.field private state:I


# direct methods
.method public constructor <init>(Landroid/content/Context;Landroid/view/View;)V
    .locals 0

    .line 55
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 56
    iput-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->ctx:Landroid/content/Context;

    const/4 p1, 0x0

    .line 57
    iput p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->state:I

    .line 58
    invoke-direct {p0, p2}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->initViews(Landroid/view/View;)V

    return-void
.end method

.method static synthetic access$000(Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;)Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$onUiListener;
    .locals 0

    .line 22
    iget-object p0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->onUiInteraction:Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$onUiListener;

    return-object p0
.end method

.method static synthetic access$100(Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;)I
    .locals 0

    .line 22
    iget p0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->state:I

    return p0
.end method

.method private initViews(Landroid/view/View;)V
    .locals 3

    const v0, 0x7f090082

    .line 63
    invoke-virtual {p1, v0}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/LinearLayout;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->buttonConnect:Landroid/widget/LinearLayout;

    const v0, 0x7f090085

    .line 64
    invoke-virtual {p1, v0}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/LinearLayout;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->buttonRefresh:Landroid/widget/LinearLayout;

    const v0, 0x7f0901d3

    .line 65
    invoke-virtual {p1, v0}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/ProgressBar;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->progressRefreshing:Landroid/widget/ProgressBar;

    const v0, 0x7f0900b4

    .line 66
    invoke-virtual {p1, v0}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/ImageView;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->connectDrawable:Landroid/widget/ImageView;

    const v0, 0x7f0901aa

    .line 67
    invoke-virtual {p1, v0}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/Spinner;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devices:Landroid/widget/Spinner;

    const v0, 0x7f0900b5

    .line 68
    invoke-virtual {p1, v0}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object p1

    check-cast p1, Landroid/widget/TextView;

    iput-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->connectText:Landroid/widget/TextView;

    .line 70
    new-instance p1, Ljava/util/ArrayList;

    invoke-direct {p1}, Ljava/util/ArrayList;-><init>()V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->pairedDevices:Ljava/util/List;

    .line 72
    new-instance p1, Landroid/widget/ArrayAdapter;

    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->ctx:Landroid/content/Context;

    new-instance v1, Ljava/util/ArrayList;

    invoke-direct {v1}, Ljava/util/ArrayList;-><init>()V

    const v2, 0x1090008

    invoke-direct {p1, v0, v2, v1}, Landroid/widget/ArrayAdapter;-><init>(Landroid/content/Context;ILjava/util/List;)V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    .line 73
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    const v0, 0x1090009

    invoke-virtual {p1, v0}, Landroid/widget/ArrayAdapter;->setDropDownViewResource(I)V

    .line 75
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devices:Landroid/widget/Spinner;

    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    invoke-virtual {p1, v0}, Landroid/widget/Spinner;->setAdapter(Landroid/widget/SpinnerAdapter;)V

    .line 77
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->buttonConnect:Landroid/widget/LinearLayout;

    new-instance v0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$1;

    invoke-direct {v0, p0}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$1;-><init>(Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;)V

    invoke-virtual {p1, v0}, Landroid/widget/LinearLayout;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    .line 84
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->buttonRefresh:Landroid/widget/LinearLayout;

    new-instance v0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$2;

    invoke-direct {v0, p0}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$2;-><init>(Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;)V

    invoke-virtual {p1, v0}, Landroid/widget/LinearLayout;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    return-void
.end method


# virtual methods
.method public addBluetoothDevice(Landroid/bluetooth/BluetoothDevice;)V
    .locals 2

    if-eqz p1, :cond_2

    .line 172
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->pairedDevices:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->contains(Ljava/lang/Object;)Z

    move-result v0

    if-nez v0, :cond_2

    .line 173
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->pairedDevices:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 175
    invoke-virtual {p1}, Landroid/bluetooth/BluetoothDevice;->getName()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-nez v0, :cond_0

    invoke-virtual {p1}, Landroid/bluetooth/BluetoothDevice;->getName()Ljava/lang/String;

    move-result-object p1

    goto :goto_0

    :cond_0
    invoke-virtual {p1}, Landroid/bluetooth/BluetoothDevice;->getAddress()Ljava/lang/String;

    move-result-object p1

    .line 177
    :goto_0
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-nez v1, :cond_1

    goto :goto_1

    :cond_1
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->ctx:Landroid/content/Context;

    const v1, 0x7f110219

    invoke-virtual {p1, v1}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object p1

    :goto_1
    invoke-virtual {v0, p1}, Landroid/widget/ArrayAdapter;->add(Ljava/lang/Object;)V

    .line 178
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    invoke-virtual {p1}, Landroid/widget/ArrayAdapter;->notifyDataSetChanged()V

    :cond_2
    return-void
.end method

.method public clearAdapter()V
    .locals 1

    .line 128
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->pairedDevices:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    .line 130
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    invoke-virtual {v0}, Landroid/widget/ArrayAdapter;->clear()V

    .line 131
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    invoke-virtual {v0}, Landroid/widget/ArrayAdapter;->notifyDataSetChanged()V

    return-void
.end method

.method public getSelectedDevice()Landroid/bluetooth/BluetoothDevice;
    .locals 2

    .line 189
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->pairedDevices:Ljava/util/List;

    if-eqz v0, :cond_0

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    if-lez v0, :cond_0

    .line 190
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->pairedDevices:Ljava/util/List;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devices:Landroid/widget/Spinner;

    invoke-virtual {v1}, Landroid/widget/Spinner;->getSelectedItemPosition()I

    move-result v1

    invoke-interface {v0, v1}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/bluetooth/BluetoothDevice;

    return-object v0

    :cond_0
    const/4 v0, 0x0

    return-object v0
.end method

.method public refreshItemState()V
    .locals 3

    .line 149
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    invoke-virtual {v0}, Landroid/widget/ArrayAdapter;->getCount()I

    move-result v0

    if-nez v0, :cond_0

    .line 150
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->ctx:Landroid/content/Context;

    const v2, 0x7f110157

    invoke-virtual {v1, v2}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/widget/ArrayAdapter;->add(Ljava/lang/Object;)V

    .line 151
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devicesAdapter:Landroid/widget/ArrayAdapter;

    invoke-virtual {v0}, Landroid/widget/ArrayAdapter;->notifyDataSetChanged()V

    .line 152
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devices:Landroid/widget/Spinner;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/widget/Spinner;->setEnabled(Z)V

    goto :goto_0

    .line 154
    :cond_0
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devices:Landroid/widget/Spinner;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Landroid/widget/Spinner;->setEnabled(Z)V

    :goto_0
    return-void
.end method

.method public setOnUiInteraction(Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$onUiListener;)V
    .locals 0

    .line 135
    iput-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->onUiInteraction:Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps$onUiListener;

    return-void
.end method

.method public setRefreshVisible(Z)V
    .locals 4

    .line 165
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->progressRefreshing:Landroid/widget/ProgressBar;

    const/4 v1, 0x0

    const/16 v2, 0x8

    if-eqz p1, :cond_0

    const/4 v3, 0x0

    goto :goto_0

    :cond_0
    const/16 v3, 0x8

    :goto_0
    invoke-virtual {v0, v3}, Landroid/widget/ProgressBar;->setVisibility(I)V

    .line 166
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->buttonRefresh:Landroid/widget/LinearLayout;

    if-eqz p1, :cond_1

    const/4 v3, 0x0

    goto :goto_1

    :cond_1
    const/16 v3, 0x8

    :goto_1
    invoke-virtual {v0, v3}, Landroid/widget/LinearLayout;->setVisibility(I)V

    .line 167
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->devices:Landroid/widget/Spinner;

    if-eqz p1, :cond_2

    goto :goto_2

    :cond_2
    const/16 v1, 0x8

    :goto_2
    invoke-virtual {v0, v1}, Landroid/widget/Spinner;->setVisibility(I)V

    return-void
.end method

.method public setRefreshing(Z)V
    .locals 4

    .line 159
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->progressRefreshing:Landroid/widget/ProgressBar;

    const/4 v1, 0x0

    const/16 v2, 0x8

    if-eqz p1, :cond_0

    const/4 v3, 0x0

    goto :goto_0

    :cond_0
    const/16 v3, 0x8

    :goto_0
    invoke-virtual {v0, v3}, Landroid/widget/ProgressBar;->setVisibility(I)V

    .line 160
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->buttonRefresh:Landroid/widget/LinearLayout;

    if-eqz p1, :cond_1

    const/16 v1, 0x8

    :cond_1
    invoke-virtual {v0, v1}, Landroid/widget/LinearLayout;->setVisibility(I)V

    .line 161
    iget-object v0, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->buttonConnect:Landroid/widget/LinearLayout;

    xor-int/lit8 p1, p1, 0x1

    invoke-virtual {v0, p1}, Landroid/widget/LinearLayout;->setEnabled(Z)V

    return-void
.end method

.method public setState(I)V
    .locals 3

    const/4 v0, 0x1

    const/4 v1, 0x0

    if-eqz p1, :cond_3

    if-eq p1, v0, :cond_2

    const/4 v2, 0x2

    if-eq p1, v2, :cond_1

    const/4 v2, 0x3

    if-ne p1, v2, :cond_0

    .line 115
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->setRefreshVisible(Z)V

    .line 116
    invoke-virtual {p0, v0}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->toggleConnectionDrawable(Z)V

    .line 117
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->setRefreshing(Z)V

    goto :goto_0

    .line 121
    :cond_0
    new-instance v0, Ljava/lang/IllegalArgumentException;

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "Wrong state is given("

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string p1, ")"

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p1

    invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 109
    :cond_1
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->setRefreshVisible(Z)V

    .line 110
    invoke-virtual {p0, v0}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->toggleConnectionDrawable(Z)V

    .line 111
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->setRefreshing(Z)V

    goto :goto_0

    .line 103
    :cond_2
    invoke-virtual {p0, v0}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->setRefreshVisible(Z)V

    .line 104
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->toggleConnectionDrawable(Z)V

    .line 105
    invoke-virtual {p0, v0}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->setRefreshing(Z)V

    goto :goto_0

    .line 96
    :cond_3
    invoke-virtual {p0, v0}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->setRefreshVisible(Z)V

    .line 97
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->toggleConnectionDrawable(Z)V

    .line 98
    invoke-virtual {p0, v1}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->setRefreshing(Z)V

    .line 99
    invoke-virtual {p0}, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->refreshItemState()V

    .line 124
    :goto_0
    iput p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->state:I

    return-void
.end method

.method public toggleConnectionDrawable(Z)V
    .locals 1

    if-nez p1, :cond_0

    .line 140
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->connectDrawable:Landroid/widget/ImageView;

    const v0, 0x7f0800d4

    invoke-virtual {p1, v0}, Landroid/widget/ImageView;->setImageResource(I)V

    .line 141
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->connectText:Landroid/widget/TextView;

    const v0, 0x7f110093

    invoke-virtual {p1, v0}, Landroid/widget/TextView;->setText(I)V

    goto :goto_0

    .line 143
    :cond_0
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->connectDrawable:Landroid/widget/ImageView;

    const v0, 0x7f0800d5

    invoke-virtual {p1, v0}, Landroid/widget/ImageView;->setImageResource(I)V

    .line 144
    iget-object p1, p0, Llt/noframe/gpsfarmguide/widgets/ButtonHelperGps;->connectText:Landroid/widget/TextView;

    const v0, 0x7f1100ad

    invoke-virtual {p1, v0}, Landroid/widget/TextView;->setText(I)V

    :goto_0
    return-void
.end method
